package com.allwees.support.marketing.dto;

import com.allwees.support.marketing.constant.AdjustPriceRuleCode;
import com.allwees.support.marketing.domain.AdjustPriceRule;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
public class AdjustProductPriceDTO {

    @NotNull(groups = Add.class, message = "规则编码为空~")
    private AdjustPriceRuleCode code;

    @NotEmpty(groups = {Add.class, Edit.class}, message = "规则为空")
    private String content;

    @NotNull(groups = {Edit.class, De.class}, message = "ID为空")
    private Long id;

    public AdjustPriceRule toUpdateEntity() {
        AdjustPriceRule rule = new AdjustPriceRule();
        rule.setRuleContent(content);
        rule.setId(id);
        return rule;
    }

    public AdjustPriceRule toSaveEntity() {
        AdjustPriceRule rule = new AdjustPriceRule();
        rule.setRuleName(code.getRuleName());
        rule.setRuleCode(code);
        rule.setRuleContent(content);
        return rule;
    }

    public interface Add {
    }

    public interface Edit {
    }

    public interface De {
    }
}
